package Test.Login_teacher.application;

import java.io.*;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Client {
    //客户端的登录
    public void login(){
        //登录服务器
        try {
            Socket client = new Socket("127.0.0.1",8088);
            BufferedReader bw = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
            PrintWriter pw = new PrintWriter(new OutputStreamWriter(client.getOutputStream(),StandardCharsets.UTF_8));
            //接收用户输入数据
            Scanner s = new Scanner(System.in);
            System.out.println("请输入用户名");
            String  userName = s.nextLine();
            System.out.println("请输入密码");
            String  password = s.nextLine();
            String userInfo = userName+"#"+password;
            pw.println(userInfo);
            pw.flush();
            System.out.println(bw.readLine());
            pw.close();
            bw.close();
            client.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
